# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=art_standalone
pkgver=0_git20241001
pkgrel=0
_commit="c4d890772a4baa583ef5caea03e8a2a351871e5d"
pkgdesc="A standalone version of Dalvik with Art build in"
url="https://gitlab.com/android_translation_layer/dalvik_standalone"
arch="x86_64 aarch64 armv7"
license="Apache-2.0"
depends="wolfssl-jni"
# bash is used by /usr/bin/dx
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	bash
	"
case "$CARCH" in
	aarch64|armv7) depends_dev="$depends_dev vixl-dev" ;;
esac
makedepends="$depends_dev
	bionic_translation-dev
	bsd-compat-headers
	expat-dev
	icu-dev
	java-common
	libbsd-dev
	libcap-dev
	libunwind-dev
	lz4-dev
	meson
	openjdk8-jdk
	openssl-dev
	python3
	valgrind-dev
	wolfssl-jni-dev
	xz-dev
	zip
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-dbg"
source="https://gitlab.com/android_translation_layer/art_standalone/-/archive/$_commit/art_standalone-$_commit.tar.gz"
options="!check" # No tests
builddir="$srcdir/art_standalone-$_commit"

prepare() {
	default_prepare

	# Hack
	ln -s /usr/bin/python3 python
	export PATH="$PATH:$PWD"
}

build() {
	make PREFIX=/usr ____LIBDIR=lib
}

package() {
	DESTDIR="$pkgdir" make \
		____PREFIX="$pkgdir"/usr \
		____INSTALL_ETC="$pkgdir"/etc \
		____LIBDIR=lib \
		install
}

dev() {
	default_dev

	mkdir -p "$subpkgdir"/usr/lib/java
	mv "$pkgdir"/usr/lib/java/core-all_classes.jar "$subpkgdir"/usr/lib/java
	mv "$pkgdir"/usr/lib/java/dx.jar "$subpkgdir"/usr/lib/java
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/dx "$subpkgdir"/usr/bin/dx
}

sha512sums="
f69d4723e44919e22f910356c6b11295d7adcb8d5e81befa8dc8d32cd5d793575cda659ba248d68751dda3bf050267d36836afa663efe6ba3396d71e63da5f43  art_standalone-c4d890772a4baa583ef5caea03e8a2a351871e5d.tar.gz
"
